﻿<UserControl
    x:Class="mal.Web.Silverlight.MEF.Shell.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation" 
    xmlns:uriMapper="clr-namespace:System.Windows.Navigation;assembly=System.Windows.Controls.Navigation"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:MEFLoader="clr-namespace:mal.Web.Silverlight.MEF.Core.ContentLoader;assembly=mal.Web.Silverlight.MEF.Core"
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"
     DataContext="{Binding Main, Source={StaticResource Locator}}"
    >
    <UserControl.Resources>

    </UserControl.Resources>

    <Grid x:Name="LayoutRoot" Style="{StaticResource LayoutRootGridStyle}">

        <Border x:Name="ContentBorder" Style="{StaticResource ContentBorderStyle}">

            <navigation:Frame x:Name="ContentFrame" Style="{StaticResource ContentFrameStyle}" 
                              Source="Home" Navigated="ContentFrame_Navigated" NavigationFailed="ContentFrame_NavigationFailed">
                <navigation:Frame.UriMapper>
                    <uriMapper:UriMapper>
                        <uriMapper:UriMapping Uri="Home/{Id}/{Code}" MappedUri="mal.Web.Silverlight.MEF.Module1.xap;Home?id={Id}&amp;code={Code}"/>
                        <uriMapper:UriMapping Uri="Home/{Id}" MappedUri="mal.Web.Silverlight.MEF.Module1.xap;Home?id={Id}"/>
                        <uriMapper:UriMapping Uri="Home" MappedUri="mal.Web.Silverlight.MEF.Module1.xap;Home"/>
                        <uriMapper:UriMapping Uri="About" MappedUri="mal.Web.Silverlight.MEF.Module1.xap;About"/>
                        <uriMapper:UriMapping Uri="Page1" MappedUri="mal.Web.Silverlight.MEF.Module2.xap;Page1"/>
                        
                    </uriMapper:UriMapper>
                </navigation:Frame.UriMapper>
                <navigation:Frame.ContentLoader>
                    <MEFLoader:MEFContentLoader />
                </navigation:Frame.ContentLoader>
            </navigation:Frame>
        </Border>

        <Grid x:Name="NavigationGrid" Style="{StaticResource NavigationGridStyle}">

            <Border x:Name="BrandingBorder" Style="{StaticResource BrandingBorderStyle}">
                <StackPanel x:Name="BrandingStackPanel" Style="{StaticResource BrandingStackPanelStyle}">

                    <ContentControl Style="{StaticResource LogoIcon}"/>
                    <TextBlock x:Name="ApplicationNameTextBlock" Style="{StaticResource ApplicationNameStyle}" 
                               Text="MEF and Load on Demand"/>

                </StackPanel>
            </Border>

            <Border x:Name="LinksBorder" Style="{StaticResource LinksBorderStyle}">
                <StackPanel x:Name="LinksStackPanel" Style="{StaticResource LinksStackPanelStyle}">

                    <Border CornerRadius="5" BorderBrush="White" BorderThickness="2" Margin="0 0 5 0">                        
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="Module 1" Style="{StaticResource TextStyle}"></TextBlock>
                            <Rectangle Style="{StaticResource DividerStyle}"/>
                            <HyperlinkButton x:Name="Link1" Style="{StaticResource LinkStyle}" 
                                     NavigateUri="Home" TargetName="ContentFrame" Content="home"/>

                            <Rectangle Style="{StaticResource DividerStyle}"/>

                            <HyperlinkButton x:Name="Link2" Style="{StaticResource LinkStyle}" 
                                     NavigateUri="About" TargetName="ContentFrame" Content="about"/>
                        </StackPanel>
                    </Border>

                    <Border CornerRadius="5" BorderBrush="White" BorderThickness="2">
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="Module 2" Style="{StaticResource TextStyle}"></TextBlock>
                            <Rectangle Style="{StaticResource DividerStyle}"/>
                            <HyperlinkButton  Style="{StaticResource LinkStyle}" 
                                     NavigateUri="Page1" TargetName="ContentFrame" Content="page1"/>
                        </StackPanel>
                    </Border>

                </StackPanel>
            </Border>

        </Grid>

        <Grid Visibility="{Binding IsBusy, Converter={StaticResource BooleanToVisibilityConverter}}">
            <Rectangle Fill="Gray" Opacity="0.4"></Rectangle>
            <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="26" Text="Loading..." />
        </Grid>
    </Grid>

</UserControl>